
class  Test{
    public int value=0;
}
public class ThreadDemo10isFinished {
    private static boolean isFinshed=false;
    public static void main(String[] args) throws InterruptedException {
        Test test=new Test();

        Thread t=new Thread(()->{
            while (!isFinshed){
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("thread结束");
            System.out.println(test.value);
            test.value++;
        });
       t.start();
       Thread.sleep(3000);
       isFinshed=true;
    }
}
